package cn.itsource.pethome.mylistener;

import cn.itsource.pethome.system.permission.service.IPermissionService;

import javax.annotation.Resource;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener //让springboot启动的时候知道
public class PermissionScanInitListener implements ServletContextListener {

    @Resource
    private IPermissionService permissionService;
    
    //spring容器初始化结束之后被调用
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        new Thread(new Runnable() {//新开一个子线程去扫描所有权限
            @Override
            public void run() {
                System.out.println("权限初始化开始******************************************");
                permissionService.scanPermission();
                System.out.println("权限初始化结束******************************************");
            }
        }).start();
    }
}